using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; using MonoMod.RuntimeDetour; using System.Reflection; using System.Collections; namespace SpidersBegone { public class SpidersBegoneModule : ETGModule { public static readonly string MOD_NAME = "Spiders Begone Ver."; public static readonly string VERSION = "1.0"; public static readonly string TEXT_COLOR = "#00adfc"; public override void Start() { bool Setup = true; try { AIAnimator aiAnimator = EnemyDatabase.GetOrLoadByGuid("6c43fddfd401456c916089fdd1c99b1c").aiAnimator; List namedVFX = aiAnimator.OtherVFX; foreach (AIAnimator.NamedVFXPool pool in namedVFX) { if (pool.name == "mergo") { foreach (VFXComplex vFXComplex in pool.vfxPool.effects) { foreach (VFXObject vFXObject in vFXComplex.effects) { VFXObject myVFX = SpidersBegoneModule.CopyFields(vFXObject); HighPriestClapVFX = new VFXPool(); HighPriestClapVFX.type = VFXPoolType.Single; HighPriestClapVFX.effects = new VFXComplex[] { new VFXComplex() { effects = new VFXObject[] { myVFX } } }; } } } } new Hook(typeof(AIActor).GetMethod("Start", BindingFlags.Instance | BindingFlags.Public), typeof(SpidersBegoneModule).GetMethod("DeletesSpiderus")); new Hook(typeof(AIActor).GetMethod("HandleReinforcementFallIntoRoom", BindingFlags.Instance | BindingFlags.Public), typeof(SpidersBegoneModule).GetMethod("DeletesSpiderusHandleReinforcementFallIntoRoom")); } catch (Exception ex) { Setup = false; Log($"Something went wrong setting up the mod!", TEXT_COLOR); ETGModConsole.Log(ex.ToString()); } string Str = Setup == true ? "successfully." : "unsuccessfully."; Log($"{MOD_NAME} v{VERSION} started " + Str, TEXT_COLOR); } public static VFXObject CopyFields(VFXObject sample2) where T : VFXObject { VFXObject sample = new VFXObject(); sample.alignment = sample2.alignment; sample.attached = sample2.attached; sample.destructible = sample2.destructible; sample.effect = sample2.effect; sample.orphaned = sample2.orphaned; sample.persistsOnDeath = sample2.persistsOnDeath; sample.usesZHeight = sample2.usesZHeight; return sample; } public static VFXPool HighPriestClapVFX; public static void DeletesSpiderus(Action orig, AIActor self) { orig(self); if (self.EnemyGuid == "98ca70157c364750a60f5e0084f9d3e2") { //GameManager.Instance.StartCoroutine(SpawnMiniReward(self.sprite.WorldCenter)); UnityEngine.Object.Destroy(self.gameObject); } } public static void DeletesSpiderusHandleReinforcementFallIntoRoom(Action orig, AIActor self, float fl) { if (self.EnemyGuid == "98ca70157c364750a60f5e0084f9d3e2") { GameManager.Instance.StartCoroutine(SpawnMiniReward(self.sprite.WorldCenter)); return; } orig(self, fl); } private static IEnumerator SpawnMiniReward(Vector2 enemyPos) { HighPriestClapVFX.SpawnAtPosition(enemyPos); float ela = 0; while (ela < 1) { ela += BraveTime.DeltaTime; yield return null; } LootEngine.SpawnItem(PickupObjectDatabase.GetById(70).gameObject, enemyPos, Vector2.zero, 0f, true, false, false); yield break; } public static void Log(string text, string color="#FFFFFF") { ETGModConsole.Log($"{text}"); } public override void Exit() { } public override void Init() { } } }